﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title></title>
    <link href="../CSS/style1.css" rel="stylesheet" type="text/css" />
    <link href="../CSS/style4.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../DatePicker/WdatePicker.js"></script>
    <script src="../Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script src="../Scripts/jquery.showModalDialog.js" type="text/javascript"></script>
    <script type="text/javascript">
        //时间格式转换
        function date2str(date) {
            //null判断
            if (date == null) return "";
            //去掉左右的斜杠
            date = date.replace(/\//g, "");
            //将其转为一个日期对象
            eval("var d = new " + date + ";");
            //返回最终结果
            return d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate();
        }
        //得到ID
        var ID = window.dialogArguments.id;
        //加载显示
        $(function () {
            
            reloadList();
        })
        function reloadList() {
            //通过id将资料从数据库中查询出来
            $.ajax({
                url: "QuanBuAll.asmx/FindActivitys",
                type: "post",
                data: JSON.stringify({ id: parseInt(ID) }),
                dataType: "json",
                contentType: "application/json",
                success: function (obj) {

                    $("#txt1").val(date2str(obj.d.ActDate)),
                    $("#txt2").val(obj.d.ActAdd),
                    $("#txt3").val(obj.d.ActTitle),
                    $("#txt4").val(obj.d.ActMemo),
                    $("#txt5").val(obj.d.ActDesc)

                }, error: function (xmlhttp) {
                    alert("错误：" + xmlhttp.responseText);
                }
            });
        }
        function ok() {
            var ac = {
                action: "ActivitysEdit",
                ActID:ID,
                ActDate:$("#txt1").val(),
                ActAdd: $("#txt2").val(),
                ActTitle: $("#txt3").val(),
                ActMemo: $("#txt4").val(),
                ActDesc: $("#txt5").val()
            };
            //发起更新请求
            $.get("CustomerAll.ashx", ac, function (r) {
                if (r == "1") {
                    alert("编辑成功");
                    window.returnValue = true;
                    window.close();
                } else {
                    alert("编辑失败");
                }
            });
        }
    </script>
</head>
<body>
<table class="tableEdit">
        <thead>
            <tr>
                <td colspan="4">编辑客户来往记录</td>
            </tr>
        </thead>
        <tr>
            <th>交往时间：</th>
            <td>
                <input type="text" style="color:blue;width:120px" id="txt1" onclick="WdatePicker()" /></td>
            <th>交往地点：</th>
            <td>
                <input type="text" id="txt2" style="color:blue;width:120px" />
            </td>
        </tr>
        <tr>
            <th>概要：</th>
            <td><textarea id="txt3" style="color:blue;height:40px;width:120px"></textarea></td>
            <th>备注：</th>
            <td><textarea id="txt4" style="color:blue;height:40px;width:120px"></textarea></td>
        </tr>
        <tr>
            <th>详细描述：</th>
            <td colspan="3"><textarea id="txt5" style="color:blue;width:100%"></textarea></td>
        </tr>
        <tfoot>
            <tr>
                <td colspan="4">
                    <input type="button" value="确定" onclick="ok();" />&nbsp;&nbsp;
                    <input type="button" value="关闭" onclick="window.close()" />
                </td>
            </tr>
        </tfoot>
    </table>
</body>
</html>
